package com.baoteng.rbspy.config;

import java.util.concurrent.CountDownLatch;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.baoteng.rbspy.mq.MessageHandler;

public class RedisMessageReceiver  {
	
	private static final Logger logger = LoggerFactory.getLogger(RedisMessageReceiver.class);

    private CountDownLatch latch;

    @Autowired
    MessageHandler consumer;
    
    @Autowired
    public RedisMessageReceiver(CountDownLatch latch) {
        this.latch = latch;
    }

    public void receiveMessage(String message) {
    	logger.info("Received <{}>",message);
    	consumer.consumer(message);
        latch.countDown();
    }
    

}
